
package org.xs.big_event.utils;

public  enum ResponseEnum {
    SUCCESS(200, "操作成功"),
    FAIL(300, "获取数据失败"),
    USER_NOT_EXIST(301, "用户不存在，请重新登录"),
    ERROR(302, "错误请求"),
    USERNAME_PASSWORD_ERROR(303, "用户名或密码错误"),
    NO_TOKEN(400, "无token，请重新登录"),
    TOKEN_VERIFY_ERROR(401, "token验证失败，请重新登录"),
    TOKEN_EX(402, "token已过期"),
    USER_EXIST(403, "用户已存在"),
    CATEGORY_EXIST(405,"该文章分类已存在"),
    CATEGORY_NOT_EXIST(406,"不存在该文章分类"),
    PARAM_ERROR(408,"标题不能为空" ),
    FILE_UPLOAD_ERROR(501, "文件上传错误"),
    FILE_EMPTY(409,"文件不能为空" );

    private final Integer code;
    private final String mag;

    public static ResponseEnum getResponseEnum(Integer code) {
        for(ResponseEnum responseEnum : values()) {
            if (responseEnum.code.equals(code)) {
                return responseEnum;
            }
        }

        return null;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMag() {
        return this.mag;
    }

    private ResponseEnum(final Integer code, final String mag) {
        this.code = code;
        this.mag = mag;
    }
}
